package main

type ListNode struct {
	Val  int
	Next *ListNode
}
//更好的办法就是开辟一个10000长度的slice 倒叙插入然后顺序打印
func reversePrint(head *ListNode) []int {
	if head == nil {
		return []int{}
	}
	v := make([]int, 10)
	for head != nil {
		v := append(v, head.Val)
		head = head.Next

	}
	reverse(v)

	return v

}

func reverse(arr *[]int) {
	length := len(*arr)
	var temp int
	for i := 0; i < length/2; i++ {
		temp = (*arr)[i]
		(*arr)[i] = (*arr)[length-1-i]
		(*arr)[length-1-i] = temp
	}

func main() {

}
